home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
c
/
ansippv2.zip
/
ASSERT.H
< prev
next >
Wrap
C/C++ Source or Header
|
1988-09-13
|
2KB
|
64 lines
/*
** ASSERT.H
** TLIB Keyword "%v %f %w"
** "5 13-Sep-88,19:07:06 SBW'"
**
** 09/20/87 sbw Created
** 09/01/88 sbw The NDEBUG macro worked backwards.
** 09/12/88 sbw Protect from repeated inclusion. Include necessary
** prototypes.
**
** Distribute this program freely, provided that no charge is made, and that
** this notice is retained. To receive the latest version, along with source
** code, send $15 to the author. This program may be used for private,
** non-commercial use only. For commercial use, contact the author:
**
** Steven Bruce Williams
** Brewster Station
** P.O. Box 8458
** Bridgeport, CT 06605-0997
**
** This is an ANSI-conforming implementation if the assert() macro. This may
** be used with any K&R C compiler.
*/
#ifndef assert
#ifndef NDEBUG
/*
** STDIO.H must be included to define fprintf().
** STDLIB.H must be included to define exit().
** ANSI requires that each of these are protected from repeated inclusion, so
** it doesn't matter if the source code includes both ASSERT.H and either or
** both of STDIO.H and STDLIB.H.
*/
#include <stdio.h>
#include <stdlib.h>
#define assert(condition) \
((void)(!(condition) ? (fprintf(stderr, \
"Assertion failed: " \
#condition \
", file " \
__FILE__ \
", line %u\n", \
__LINE__ \
) , \
exit(-1) , \
0 \
) \
: 0 \
) \
)
#else
#define assert(ignore)
#endif
#endif